package com.pengcheng.taskapplication.mvp.view.activity;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.TextView;

import com.pengcheng.taskapplication.R;
import com.pengcheng.taskapplication.adapter.FragmentAdapter;
import com.pengcheng.taskapplication.contants.ConstantValue;
import com.pengcheng.taskapplication.model.TabItem;
import com.pengcheng.taskapplication.mvp.view.fragment.MyParkListFragment;
import com.pengcheng.taskapplication.mvp.view.fragment.MyWashListFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

public class MyParkAndWashList  extends BaseActivity{
    @BindView(R.id.tb_top)
    TabLayout tabLayout;
    @BindView(R.id.vp_show)
    ViewPager viewPager;
    @BindView(R.id.tv_center_title)
    TextView tv_center_title;

    private List<Fragment> fragmentList =new ArrayList<Fragment>();
    private List<TabItem> tabItemList = new ArrayList<>();

    @Override
    protected int layoutResID() {
        return R.layout.activity_my_park_wash_list_layout;
    }

    @Override
    protected void initData() {
        int tab = getIntent().getIntExtra(ConstantValue.IntentKey.KEY_FROM_TYPE, 0);
        tv_center_title.setText("我的订单");
        TabItem tabItem=new TabItem();
        tabItem.setName("洗车订单");
        tabItemList.add(tabItem);
        TabItem tabItem2=new TabItem();
        tabItem2.setName("停车订单");
        tabItemList.add(tabItem2);

        MyWashListFragment washListFragment = new MyWashListFragment();
        fragmentList.add(washListFragment);
        MyParkListFragment parkListFragment=new MyParkListFragment();
        fragmentList.add(parkListFragment);

        FragmentAdapter adapter = new FragmentAdapter(getSupportFragmentManager(), tabItemList, fragmentList);
        viewPager.setOffscreenPageLimit(fragmentList.size());
        viewPager.setAdapter(adapter);
        tabLayout.setupWithViewPager(viewPager);
        viewPager.setCurrentItem(tab);

    }
    @OnClick({R.id.img_back})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.img_back:
                MyParkAndWashList.this.finish();
                break;
        }
    }

}
